package com.mogu.biguser.common.util;/*
package com.mogu.safedeal.common.util;

import com.mogo.workorder.domain.urgent.WorkorderInfo;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;

import java.io.*;
import java.util.ArrayList;
import java.util.List;


public class ExclePoi {
    */
/**
     * 针对Book类进行导出的操作
     *
     * @param list
     *//*

    public static void excleOut(List<WorkorderInfo> list) {
        // 创建Excel文档
        HSSFWorkbook hwb = new HSSFWorkbook();
        // 通过excle对象创建一个选项卡对象
        HSSFSheet sheet = hwb.createSheet("sheet1");
        WorkorderInfo workorderInfo=null;
        // 循环list创建行
        for (int i = 0; i < list.size(); i++) {
            // 新建一行
            HSSFRow row = sheet.createRow(i);
          workorderInfo = list.get(i);
            // 设置i+1行第0列的数据
            row.createCell(0).setCellValue(workorderInfo.getOrderId());
            // 设置i+1行第1列的数据
          */
/*  row.createCell(1).setCellValue(book.getName());
            // 设置i+1行第2列的数据
            row.createCell(2).setCellValue(book.getAuthor());*//*

        }
        OutputStream out = null;
        try {
            out = new FileOutputStream("d:/excleTest/bookPoi.xls");
            hwb.write(out);
            System.err.println("导出成功");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
            System.err.println("导出失败");
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    public static HSSFWorkbook getHSSFWorkbook(String sheetName, String[] title, String[][] content, HSSFWorkbook wb) {
        // 第一步，创建一个HSSFWorkbook，对应一个Excel文件
        if(wb == null){
            wb = new HSSFWorkbook();
        }

        // 第二步，在workbook中添加一个sheet,对应Excel文件中的sheet
        HSSFSheet sheet = wb.createSheet(sheetName);

        // 第三步，在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
        HSSFRow row = sheet.createRow(0);

        // 第四步，创建单元格，并设置值表头 设置表头居中
        HSSFCellStyle style = wb.createCellStyle();
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式

        //声明列对象
        HSSFCell cell = null;

        //创建标题
        for(int i=0;i<title.length;i++){
            cell = row.createCell(i);
            cell.setCellValue(title[i]);
            cell.setCellStyle(style);
        }

        //创建内容
        for(int i=0;i<content.length;i++){
            row = sheet.createRow(i + 1);
            for(int j=0;j<content[i].length;j++){
                //将内容按顺序赋给对应的列对象
                row.createCell(j).setCellValue(content[i][j]);
            }
        }


        return wb;
    }


   */
/* *//*
*/
/**
     * 针对Book类进行导入的操作
     *
     * @return
     *//*
*/
/*
    public static List<WorkorderInfo> excleIn(InputStream is) {
        List<WorkorderInfo> list = new ArrayList<>();
        WorkorderInfo workorderInfo = null;
        try {
//            InputStream is = new FileInputStream("d:/excleTest/bookPoi.xls");
            HSSFWorkbook hssfWorkbook = new HSSFWorkbook(is);
            // 获取选项卡对象 第0个选项卡 , 因为我们这里只有一个选项卡，如果你每个选项卡的内容是一样，可以通过循环取出
            HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
            // 循环取出每行的值
            for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
                HSSFRow hssfRow = hssfSheet.getRow(rowNum);
                System.err.println(rowNum);
                workorderInfo = new WorkorderInfo();
                //注意Poi读取的内容是有类型的，处理起来也jxl有所不同
                String s = System.nanoTime()+""+(int)(Math.random()*100);
                workorderInfo.setOrderId(s);
                workorderInfo.setOrderArea(hssfRow.getCell(2).getStringCellValue());
                workorderInfo.setOrderType(hssfRow.getCell(3).getStringCellValue());
                workorderInfo.setOrderOrigin(hssfRow.getCell(4).getStringCellValue());
                if (hssfRow.getCell(5)!=null) {
                    workorderInfo.setOrderName(hssfRow.getCell(5).getStringCellValue());
                }
                if (hssfRow.getCell(6)!=null){
                    workorderInfo.setOrderDesc(hssfRow.getCell(6).getStringCellValue());
                }
                hssfRow.getCell(7).setCellType(Cell.CELL_TYPE_STRING);
                workorderInfo.setOrderTimelimit(hssfRow.getCell(7).getStringCellValue());
                hssfRow.getCell(8).setCellType(Cell.CELL_TYPE_STRING);
                workorderInfo.setOrderPhone(hssfRow.getCell(8).getStringCellValue());
                workorderInfo.setOrderPipeid(hssfRow.getCell(9).getStringCellValue());
                workorderInfo.setOrderDept(hssfRow.getCell(10).getStringCellValue());
                workorderInfo.setOrderPerson(hssfRow.getCell(11).getStringCellValue());
                workorderInfo.setOrderPhotopath(hssfRow.getCell(12).getStringCellValue());
                workorderInfo.setOrderCreatename(hssfRow.getCell(13).getStringCellValue());
                workorderInfo.setOrderCreatedate(hssfRow.getCell(14).getDateCellValue());
                hssfRow.getCell(15).setCellType(Cell.CELL_TYPE_STRING);
                workorderInfo.setOrderIsovertime(hssfRow.getCell(15).getStringCellValue());
                workorderInfo.setOrderX(hssfRow.getCell(16).getNumericCellValue());
                workorderInfo.setOrderY(hssfRow.getCell(17).getNumericCellValue());
                hssfRow.getCell(18).setCellType(Cell.CELL_TYPE_STRING);
                workorderInfo.setOrderStatus(hssfRow.getCell(18).getStringCellValue());
                hssfRow.getCell(19).setCellType(Cell.CELL_TYPE_STRING);
                workorderInfo.setOrderLevel(hssfRow.getCell(19).getStringCellValue());
                workorderInfo.setOrderTag("1");
                list.add(workorderInfo);
            }
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return list;
    }
    public static void main(String[] args) {
        List<WorkorderInfo> list = new ArrayList<>();
//        Book book2 = new Book();
//        book2.setId(1);
//        book2.setName("书本名1");
//        book2.setAuthor("张三");
//        Book book3 = new Book();
//        book3.setId(2);
//        book3.setName("书本名2");
//        book3.setAuthor("李四");
//        list.add(book2);
//        list.add(book3);
//        exclePoiBook.excleOut(list);
        List<WorkorderInfo> workorderInfo = null;
        try {
            workorderInfo = ExclePoi.excleIn(new FileInputStream("d:/excleTest/bookPoi.xls"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        for (WorkorderInfo w:workorderInfo
             ) {
            System.err.println(w);
        }
    }

*//*

}*/
